---
description: "Reference for Nitric's Dart library - Creates a reference to a secret in the secrets manager."
---

# Dart - secret()

<Note>
  This is reference documentation for the Nitric Dart SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Creates a reference to a secret in the secrets manager.

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("encryptionKey").allow([
  SecretPermission.put,
  SecretPermission.access,
]);
```

## Parameters

<Properties>
  <Property name="name" required type="String">
    The unique name of this secret within the secrets manager.
  </Property>
</Properties>

## Access

All Nitric resources provide access permissions you can use to specify the level of access your service needs to the resource. See here for details about infrastructure [security](/get-started/foundations/infrastructure/security).

### Available permissions:

---

**SecretPermission.put**

This permission allows your service to set a new latest value for a secret.

---

**SecretPermission.access**

This permission allows your service to retrieve secret values.

---

## Examples

### Create a reference to a secret

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("encryptionKey").allow([
  SecretPermission.put,
  SecretPermission.access,
]);
```

### See also

- [secret().put()](./secret-put)
- [secret().version()](./secret-version)
- [secret().latest()](./secret-latest)
- [secret().version().access()](./secret-version-access)
